package com.pureut.storage.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.pureut.common.core.message.RocketMqUtils;
import com.pureut.storage.dto.MessageRemindDto;
import org.springframework.beans.factory.annotation.Value;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 物料发送管理类
 * @Param MaterialMq
 * @Date 23-02-20
 * @Author hl
 **/
public class MessageRemindMqUtil {

    @Value("${rocketmq.name-server}")
    private static String mqServer;

    @Value("${producer.group}")
    private static String mqGroup;

    @Value("${producer.send-message-timeout}")
    private static int mqTimeOut;

    /**
     * 消息提醒（mq)
     */
    public static void messageRemind(List<MessageRemindDto> list) throws Exception {

        ObjectMapper mapper = new ObjectMapper();

        List<String> stringList = new ArrayList<>();

        for (MessageRemindDto mq : list) {
            String json = mapper.writeValueAsString(mq);
            stringList.add(json);
        }

        RocketMqUtils rocketMqUtils = new RocketMqUtils("192.168.0.93:9876", "producer-socket-group", "messageRemind",3000);
        rocketMqUtils.sendMq("producer-socket-group",stringList);
    }


}
